<?php
if (!function_exists('wrapperResponse')) {
    /**
     * format data.
     * @param $status
     * @param $code
     * @param $msg
     * @param $data
     * @return array
     */
    function wrapperResponse($code, $msg, $data)
    {
        return [
            'code' => $code,
            'message' => $msg,
            'data' => $data,
        ];
    }
}

if (!function_exists('successReturn')) {
    /**
     * success return.
     * @param string $msg
     * @param null $data
     * @return array
     */
    function successReturn($msg = '操作成功', $data = null)
    {
        return wrapperResponse(0, $msg, $data);
    }
}

if (!function_exists('failReturn')) {
    function failReturn($code = 1001, $msg = '系统异常')
    {
        return wrapperResponse($code, $msg, null);
    }
}

if (!function_exists('getUploadPath')) {
    function getUploadPath($path) {
        $host = config('sdk.qiniu')['host'];
        return $host . $path;
    }
}
